import api from '@/services/customer/points-withdrawal';

export type PointsWithdrawal = PointsWithdrawalApi.InfoResponse;
export type PointsWithdrawalList = PointsWithdrawalApi.ListResponse;
export const getFilterList = async () => {
  const res = await api.getFilterList();
  return res.data;
};
export const getList = async (params: PointsWithdrawalApi.ListParams) => {
  const res = await api.getList<PointsWithdrawalList>(params);
  const tableData: Requestor.TableFormatedData<PointsWithdrawalList> = {
    data: res.listData,
    current: res.page + 1,
    pageSize: res.limit,
    total: res.count,
    success: res.success,
  };

  return tableData;
};

export const getInfo = async (params: PointsWithdrawalApi.InfoParams) => {
  const res = await api.getInfo<PointsWithdrawal>(params);
  return res.data;
};
export const updateStatus = async (params: PointsWithdrawalApi.StatusParams) => {
  const data = await api.updateStatus(params);
  return data;
};
export default {
  getFilterList,
  getList,
  getInfo,
  updateStatus,
};
